Extract at points from Serafin 2D


In [6]:
from pyteltools.geom import Shapefile
from pyteltools.slf.interpolation import MeshInterpolator
from pyteltools.slf import Serafin


points = [(97.0, 32.5), (97.5, 33.5)]

with Serafin.Read('../scripts_PyTelTools_validation/data/Yen/fis_yen-exp.slf', 'en') as resin:
    resin.read_header()
    resin.get_time()

    # Determine mesh interpolation
    mesh = MeshInterpolator(resin.header, True)
    is_inside, point_interpolators = mesh.get_point_interpolators(points)
    nb_inside = sum(map(int, is_inside))
    print("%i points are inside the mesh" % nb_inside)

    # Interpolate one variable (BOTTOM) and one frame only (the last)
    values = resin.read_var_in_frame(0, 'S')

    results = []
    for pt_id, (point, point_interpolator) in enumerate(zip(points, point_interpolators)):
        if point_interpolator is not None:
            (i, j, k), interpolator = point_interpolator
            results.append(interpolator.dot(values[[i, j, k]]))
    print(results)


Reading the input file: "../scripts_PyTelTools_validation/data/Yen/fis_yen-exp.slf" of size 2078184 bytes
WARNING: The 2D variable name "C 1ST CLASS" is not known (lang=en). The complete name will be used as ID
WARNING: The 2D variable name "PRIVE 1" is not known (lang=en). The complete name will be used as ID
WARNING: The 2D variable name "PRIVE 2" is not known (lang=en). The complete name will be used as ID
2 points are inside the mesh
[10.052406803669136, 10.050774145984624]